

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/favicon.png">
  <link rel="icon" href="/img/favicon.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="Fly542">
  <meta name="keywords" content="">
  
    <meta name="description" content="概念Lex代表词法分析器(Lexical Analyzar)。 Lex读取输入源将匹配的字符串转换为标志(token)，匹配的方式是使用正则表达式。每个匹配的模式(pattern)都对应一个动作(action)，一般情况下，动作是返回一个标志，代表匹配的字符串。 Lex的限制。Lex不能识别嵌套的结构(如括号)，因为处理嵌套结构需要一个栈，而lex没有。对此的处理使用yacc来实现。 正则表达式概">
<meta property="og:type" content="article">
<meta property="og:title" content="lex使用">
<meta property="og:url" content="http://fly542.cn/2022/10/21/04DevOps/20lex%E4%BD%BF%E7%94%A8/index.html">
<meta property="og:site_name" content="Fly542 技术沉淀">
<meta property="og:description" content="概念Lex代表词法分析器(Lexical Analyzar)。 Lex读取输入源将匹配的字符串转换为标志(token)，匹配的方式是使用正则表达式。每个匹配的模式(pattern)都对应一个动作(action)，一般情况下，动作是返回一个标志，代表匹配的字符串。 Lex的限制。Lex不能识别嵌套的结构(如括号)，因为处理嵌套结构需要一个栈，而lex没有。对此的处理使用yacc来实现。 正则表达式概">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2022-10-21T06:01:32.000Z">
<meta property="article:modified_time" content="2022-12-30T03:33:01.442Z">
<meta property="article:author" content="Fly542">
<meta property="article:tag" content="linux">
<meta name="twitter:card" content="summary_large_image">
  
  
  <title>lex使用 - Fly542 技术沉淀</title>

  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4/dist/css/bootstrap.min.css" />


  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/github-markdown-css@4/github-markdown.min.css" />
  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/hint.css@2/hint.min.css" />

  
    
    
      
      <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@10/styles/github-gist.min.css" />
    
  

  
    <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3/dist/jquery.fancybox.min.css" />
  


<!-- 主题依赖的图标库，不要自行修改 -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_ba1fz6golrf.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/css/main.css" />

<!-- 自定义样式保持在最底部 -->


  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    var CONFIG = {"hostname":"fly542.cn","root":"/","version":"1.8.14","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"right","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"copy_btn":true,"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml"};
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
<meta name="generator" content="Hexo 6.0.0"></head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>Fly542 技术沉淀</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              &nbsp;<i class="iconfont icon-search"></i>&nbsp;
            </a>
          </li>
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="banner" id="banner" parallax=true
         style="background: url('/img/default.png') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="page-header text-center fade-in-up">
            <span class="h2" id="subtitle" title="lex使用">
              
            </span>

            
              <div class="mt-3">
  
  
    <span class="post-meta">
      <i class="iconfont icon-date-fill" aria-hidden="true"></i>
      <time datetime="2022-10-21 14:01" pubdate>
        2022年10月21日 下午
      </time>
    </span>
  
</div>

<div class="mt-1">
  
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      2.7k 字
    </span>
  

  
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      23 分钟
    </span>
  

  
  
</div>

            
          </div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div class="py-5" id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">lex使用</h1>
            
            <div class="markdown-body">
              <h1 id="概念"><a href="#概念" class="headerlink" title="概念"></a>概念</h1><p>Lex代表词法分析器(Lexical Analyzar)。</p>
<p>Lex读取输入源将匹配的字符串转换为标志(token)，匹配的方式是使用正则表达式。每个匹配的模式(pattern)都对应一个动作(action)，一般情况下，动作是返回一个标志，代表匹配的字符串。</p>
<p>Lex的限制。Lex不能识别嵌套的结构(如括号)，因为处理嵌套结构需要一个栈，而lex没有。对此的处理使用yacc来实现。</p>
<h2 id="正则表达式概述"><a href="#正则表达式概述" class="headerlink" title="正则表达式概述"></a>正则表达式概述</h2><table>
<thead>
<tr>
<th>关键词</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td>.</td>
<td>匹配任何字符(除了新行符)</td>
</tr>
<tr>
<td>\n</td>
<td>新行符(newline)</td>
</tr>
</tbody></table>
<ul>
<li>   | 匹配0个或多个前面模式的拷贝</li>
</ul>
<ul>
<li>   | 匹配一个或多个前面模式的拷贝<br>?    | 匹配0个或1个前面模式的拷贝<br>^    | 匹配行开头<br>$    | 匹配行尾<br>a&#124;b    | a或b<br>(ab)+    | 匹配一个或多个ab的拷贝<br>“a+b”    |匹配a+b<br>[]    | 匹配集合里的任意字符</li>
</ul>
<p>字符的特殊含义：字符”-“在字符集里两个字符之间时代表一个范围。字符”^”在字符集里作为首字符，表示”反”含义。</p>
<h2 id="匹配规则"><a href="#匹配规则" class="headerlink" title="匹配规则"></a>匹配规则</h2><p>如果有多个模式匹配同一个串，则使用匹配最长的模式；若匹配长度也相同，则使用位于前面的模式。</p>
<h1 id="Lex文件格式"><a href="#Lex文件格式" class="headerlink" title="Lex文件格式"></a>Lex文件格式</h1><p>Lex输入文件分为三个部分，使用%%来分隔每个部分。格式如下：</p>
<figure class="highlight jboss-cli"><table><tr><td class="gutter"><div class="code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></div></td><td class="code"><pre><code class="hljs jboss-cli"><span class="hljs-string">...</span> definitions <span class="hljs-string">...</span><br>%% <br><span class="hljs-string">...</span> rules <span class="hljs-string">...</span><br>%% <br><span class="hljs-string">...</span> subroutines <span class="hljs-string">...</span><br></code></pre></td></tr></table></figure>

<p>第一个%%是必须的，在它后面是规则部分。如果不定义任何规则，缺省的动作是匹配任何文本并拷贝到输出。缺省的输入和输出是stdin和stdout。</p>
<h1 id="第一部分-定义"><a href="#第一部分-定义" class="headerlink" title="第一部分 定义"></a>第一部分 定义</h1><p>这部分的C代码被拷贝到生成的C文件的头部，C代码必须用<code>&quot;%&#123;&quot;</code>和 <code>&quot;%&#125;&quot;</code>包括起来。该部分还可定义简单的匹配模式，这些定义可以在后面的规则部分使用。如：</p>
<figure class="highlight prolog"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><code class="hljs prolog">digit [<span class="hljs-number">0</span><span class="hljs-number">-9</span>]<br>letter [<span class="hljs-symbol">A</span>-<span class="hljs-symbol">Za</span>-z]<br><span class="hljs-comment">%&#123;</span><br>int count;<br><span class="hljs-comment">%&#125;</span><br><span class="hljs-comment">%%</span><br><span class="hljs-comment">/* match identifier */</span><br>&#123;letter&#125;(&#123;letter&#125;|&#123;digit&#125;)* count++;<br><span class="hljs-comment">%%</span><br></code></pre></td></tr></table></figure>
<p>在规则部分使用定义的模式必须用<code>&#123;&#125;</code>括起来，以示区别。</p>
<h1 id="第二部分-规则"><a href="#第二部分-规则" class="headerlink" title="第二部分 规则"></a>第二部分 规则</h1><p>规则中的每个模式必须开始于一行的第一列。之后是空白符(空格、制表符、新行符)和对应的动作。动作可以是一个简单的C语句或使用{}包括的多个语句。</p>
<p>文件中第一列没有内容的行都原样的拷贝到生成的C文件中。这个特性可以在lex文件中插入注释。如：</p>
<figure class="highlight arduino"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><code class="hljs arduino">%%<br><span class="hljs-comment">/* match everything except newline */</span><br>. ECHO;<br><span class="hljs-comment">/* match newline */</span><br>\n ECHO;<br>%%<br><span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">yywrap</span><span class="hljs-params">(<span class="hljs-keyword">void</span>)</span></span><br><span class="hljs-function"></span>&#123;<br>    <span class="hljs-keyword">return</span> <span class="hljs-number">1</span>;<br>&#125;<br><span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">(<span class="hljs-keyword">void</span>)</span></span><br><span class="hljs-function"></span>&#123;<br>    <span class="hljs-built_in">yylex</span>();<br>    <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;<br>&#125;<br></code></pre></td></tr></table></figure>
<p>定义了两个模式：”.”和”\n”。</p>
<p>lex本身定义了一些宏和变量。ECHO是一个宏，该宏的典型实现如下：</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs cpp"><span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> ECHO fwrite(yytext, yyleng, 1, yyout)</span><br></code></pre></td></tr></table></figure>
<h1 id="第三部分-定义函数"><a href="#第三部分-定义函数" class="headerlink" title="第三部分 定义函数"></a>第三部分 定义函数</h1><p>定义main函数和其他处理函数。</p>
<h1 id="lex的常用变量和函数-宏"><a href="#lex的常用变量和函数-宏" class="headerlink" title="lex的常用变量和函数(宏)"></a>lex的常用变量和函数(宏)</h1><table>
<thead>
<tr>
<th>变量</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td>int yylex( void )</td>
<td>Lex的入口，返回标志（token）</td>
</tr>
<tr>
<td>char *yytext</td>
<td>指向匹配的串（null结尾）</td>
</tr>
<tr>
<td>yyleng</td>
<td>匹配串的长度</td>
</tr>
<tr>
<td>yylval</td>
<td>对应标志（token）的值</td>
</tr>
<tr>
<td>int yywrap( void )</td>
<td>输入结束时调用，返回1表示结束，0表示还有数据处理</td>
</tr>
<tr>
<td>FILE *yyout</td>
<td>输出文件，缺省是stdout</td>
</tr>
<tr>
<td>FILE *yyin</td>
<td>输入文件，缺省是stdin</td>
</tr>
<tr>
<td>INITIAL</td>
<td>开始状态</td>
</tr>
<tr>
<td>BEGIN condition</td>
<td>切换开始状态</td>
</tr>
<tr>
<td>ECHO</td>
<td>输出匹配串</td>
</tr>
</tbody></table>
<p>一些lex的实现提供变量yylineno。</p>
<h1 id="处理方法"><a href="#处理方法" class="headerlink" title="处理方法"></a>处理方法</h1><h2 id="处理引号"><a href="#处理引号" class="headerlink" title="处理引号"></a>处理引号</h2><p>以双引号包围的字符串在程序中很常见，如何匹配它们呢？</p>
<p>简单的方法是：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><code class="hljs bash">%&#123;<br>char *yylval;<br><span class="hljs-comment">#include &lt;string.h&gt;</span><br>%&#125;<br>%%<br>\&quot;[^<span class="hljs-string">&quot;\n]*[&quot;</span>\n] &#123;<br>yylval = strdup(yytext+1);<br><span class="hljs-keyword">if</span> (yylval[yyleng-2] != <span class="hljs-string">&#x27;&quot;&#x27;</span>)<br>    warning(<span class="hljs-string">&quot;improperly terminated string&quot;</span>);<br><span class="hljs-keyword">else</span><br>    yylval[yyleng-2] = 0;<br><span class="hljs-built_in">printf</span>(<span class="hljs-string">&quot;found &#x27;%s&#x27;\n&quot;</span>, yylval);<br>&#125;<br></code></pre></td></tr></table></figure>

<p>上述方法不能处理串中的转义字符如 \n 和 \ 等。要加上这些功能，如下处理：</p>
<figure class="highlight lsl"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><code class="hljs lsl">%&#123;<br>char buf[<span class="hljs-number">100</span>];<br>char *s;<br>%&#125;<br>%x STRING<br>%%<br>\<span class="hljs-string">&quot;            &#123; BEGIN STRING; s = buf; &#125;</span><br><span class="hljs-string">&lt;STRING&gt;<span class="hljs-subst">\\</span>n   &#123; *s++ = &#x27;<span class="hljs-subst">\n</span>&#x27;; &#125;</span><br><span class="hljs-string">&lt;STRING&gt;<span class="hljs-subst">\\</span>t   &#123; *s++ = &#x27;<span class="hljs-subst">\t</span>&#x27;; &#125;</span><br><span class="hljs-string">&lt;STRING&gt;<span class="hljs-subst">\\</span><span class="hljs-subst">\&quot;</span>   &#123; *s++ = &#x27;<span class="hljs-subst">\&quot;</span>&#x27;; &#125;</span><br><span class="hljs-string">&lt;STRING&gt;<span class="hljs-subst">\&quot;</span>    &#123; *s = 0;</span><br><span class="hljs-string">BEGIN 0;</span><br><span class="hljs-string">printf(&quot;</span>found &#x27;%s&#x27;\n<span class="hljs-string">&quot;, buf);</span><br><span class="hljs-string">&#125;</span><br><span class="hljs-string">&lt;STRING&gt;<span class="hljs-subst">\n</span>    &#123; printf(&quot;</span>invalid <span class="hljs-type">string</span><span class="hljs-string">&quot;); exit(1); &#125;</span><br><span class="hljs-string">&lt;STRING&gt;.     &#123; *s++ = *yytext; &#125;</span><br></code></pre></td></tr></table></figure>

<p>在定义部分定义了一个独占的开始符STRING，当执行了<code>BEGIN 开始符</code>后，lex进入该独占符模式，lex只匹配以该独占符开头的模式，直到另一个BEGIN开始执行为止。</p>
<h2 id="处理保留字"><a href="#处理保留字" class="headerlink" title="处理保留字"></a>处理保留字</h2><p>如果程序中有大量的保留字要处理，比较好的方法是写一个函数来查看一个字符串是一个变量还是保留字。而不是定义一堆标志。如：</p>
<figure class="highlight reasonml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs reasonml">&#123;letter&#125;(&#123;letter&#125;<span class="hljs-pattern-match">|&#123;digit&#125;)<span class="hljs-operator">*</span>  &#123;</span><br><span class="hljs-pattern-match"><span class="hljs-built_in">int</span> i;</span><br><span class="hljs-pattern-match"><span class="hljs-keyword">if</span> ((i = res<span class="hljs-constructor">Word(<span class="hljs-params">yytext</span>)</span>) != 0)</span><br><span class="hljs-pattern-match">    return (i);</span><br><span class="hljs-pattern-match">yylval.id = sym<span class="hljs-constructor">Lookup(<span class="hljs-params">yytext</span>)</span>;</span><br><span class="hljs-pattern-match">return (<span class="hljs-constructor">IDENTIFIER</span>);</span><br><span class="hljs-pattern-match">&#125;</span><br></code></pre></td></tr></table></figure>
            </div>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                  <div class="post-meta mr-3">
                    <i class="iconfont icon-category"></i>
                    
                      <a class="hover-with-bg" href="/categories/devops/">devops</a>
                    
                  </div>
                
                
                  <div class="post-meta">
                    <i class="iconfont icon-tags"></i>
                    
                      <a class="hover-with-bg" href="/tags/linux/">linux</a>
                    
                  </div>
                
              </div>
              
                <p class="note note-warning">
                  
                    本博客所有文章除特别声明外，均采用 <a target="_blank" href="https://creativecommons.org/licenses/by-sa/4.0/deed.zh" rel="nofollow noopener noopener">CC BY-SA 4.0 协议</a> ，转载请注明出处！
                  
                </p>
              
              
                <div class="post-prevnext">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2022/11/10/04DevOps/21tcpdump%E5%AE%9E%E7%94%A8%E6%96%B9%E6%B3%95%E6%80%BB%E7%BB%93/">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">tcpdump实用方法总结</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2022/08/15/04DevOps/19%E6%8C%87%E5%AE%9Acore%E6%96%87%E4%BB%B6%E7%94%9F%E6%88%90%E4%BD%8D%E7%BD%AE/">
                        <span class="hidden-mobile">指定core文件生成位置</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->


    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
    

    
  </main>

  <footer class="text-center mt-5 py-3">
  <div class="footer-content">
     <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
  </div>
  

  

  
</footer>


  <!-- SCRIPTS -->
  
  <script  src="https://cdn.jsdelivr.net/npm/nprogress@0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nprogress@0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js" ></script>
<script  src="https://cdn.jsdelivr.net/npm/bootstrap@4/dist/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>

<!-- Plugins -->


  <script  src="/js/local-search.js" ></script>



  
    <script  src="/js/img-lazyload.js" ></script>
  



  



  
    <script  src="https://cdn.jsdelivr.net/npm/tocbot@4/dist/tocbot.min.js" ></script>
  
  
    <script  src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3/dist/jquery.fancybox.min.js" ></script>
  
  
    <script  src="https://cdn.jsdelivr.net/npm/anchor-js@4/anchor.min.js" ></script>
  
  
    <script defer src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js" ></script>
  






  <script  src="https://cdn.jsdelivr.net/npm/typed.js@2/lib/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var title = document.getElementById('subtitle').title;
      
        typing(title);
      
    })(window, document);
  </script>















<!-- 主题的启动项 保持在最底部 -->
<script  src="/js/boot.js" ></script>


</body>
</html>
